"""
Queue.put(data) => 存入数据
Queue.get() => 取出数据
"""
import time
import queue
import threading
def producter(q):
    for item in ["🍎","🍊","🍌"]:
        print(f"生产者:{item}")
        q.put(item)
        time.sleep(1)
def consumer(q):
    while True:
        item = q.get()
        if item is None:
            break
        print(f"消费者:{item}")
if __name__ == '__main__':
    q = queue.Queue(2) # 创建一个容量为3的队列
    t1 = threading.Thread(target=producter,args=(q,))
    t2 = threading.Thread(target=consumer,args=(q,))
    t1.start()
    t2.start()
    t1.join() # 等待生成者完成
    # 他丢到这个队列里面来了之后,再丢None
    q.put(None) # ["🍎","🍊","🍌",None]
    t2.join()
    print("所有的都获取到了")